import { createBrowserRouter } from 'react-router-dom'
import Layout from '@/pages/Layout'
import Login from '@/pages/Login'

import AuthRoute from '@/components/AuthRoute.js'
import { Suspense, lazy } from 'react'
    // import Home from '@/pages/Home'
    // import Article from '@/pages/Article'
    // import Publish from '@/pages/Publish'

// 将以上三个使用lazy函数导入

const Home = lazy(() => import('@/pages/Home'))
const Article = lazy(() => import('@/pages/Article'))
const Publish = lazy(() => import('@/pages/Publish'))



const router = createBrowserRouter([
    {
        path: '/',
        element: <AuthRoute><Layout /></AuthRoute>,
        children: [
            {
                index: true,
                element: <Suspense fallback={'加载中。。。。。。。。。。'}><Home /></Suspense>
            },
            {
                path: 'Article',
                element: <Suspense fallback={'加载中。。。。。。。。。。'}><Article /></Suspense>
            },
            {
                path: 'Publish',
                element: <Suspense fallback={'加载中。。。。。。。。。。'}><Publish /></Suspense>
            }

        ]

    },
    {
        path: '/login',
        element: <Login />,
    },
])

export default router